<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// 
//  admin_activity.php
//  www.6block.com
//  
//  Created by Will_Lee on 2011-05-19.
//  Copyright 2011 lishuzu. All rights reserved.
// 

class Admin_usergroup extends CI_Controller {

	 function __construct()
	 {
		parent::__construct();
 		$this->load->model('common/security_model');
		if($this->security_model->isAdminLogin() === FALSE){
          showmessage('请登录', 'admin/login/index', 3);
		}
 		$this->load->model('usergroup_model');
		//加载缓存类
		$this->load->library('datacache');
	 }

	function index()
	{
		$data = array();
		$data['list'] = $this->config->item('usergroup');
		$this->load->template('admin/admin_usergroup_tpl', $data);
	}
	
	function edit(){
		$gid = $this->input->get('gid') ? intval($this->input->get('gid', true)) : '';
		if (!$gid) {
			showmessage('没有选择用户组', 'admin/admin_usergroup/index', 3);
		}
		
		$usergroup = $this->usergroup_model->get_group($gid);
		if (submitcheck('thevaluesubmit')) {
			$set = $this->input->post('set', true);
			$setarr = array(
				'grouptitle' => $set['grouptitle'],
				'invitetime' => intval($set['invitetime']),
				);
			$this->db->where('gid', $gid);
			$this->db->update('usergroup', $setarr);
			// 用户组缓存
			$this->datacache->usergroup_cache();
			showmessage('修改成功', 'admin/admin_usergroup/edit/?gid='.$gid, 3);
		}
		$data['thevalue'] = $usergroup;
		$this->load->template('admin/admin_usergroup_edit_tpl', $data);
	}
}
?>